|
![](/i/fill.gif) |
"Chris B" <c_b### [at] btconnect com nospam> wrote:
>
> If you want a uniform distribution you probably want #declare Start =
> vrotate ( <0,0,-2>, <asind(rand(R1)*2-1),rand(R1)*360,0> );
> This compensates by adjusting the distribution of the random numbers used
> for the x rotation, providing more points in the middle (xRotation=0) and
> less as you reach the extremes (xRotation=90 and xRotation= -90). It does
> this by taking the arcsin of a random number between -1 and 1.
>
Thank you for the thorough explanation! You were correct, I meant uniformly
distributed, not evenly spaced.
I understand your approach, but it seems to only apply to placing objects on
a sphere. Is there a way to place the cylinders uniformly on the
sphere_sweep or cylinder shapes below? Is it possible to create a random
distribution of points in a space within a sphere_sweep or cylinder?
#include "colors.inc"
#include "debug.inc"
#include "math.inc"
camera {
angle 20
location<0,0,-50>
look_at<0,0,0>
}
light_source { <0, 15, 10> color White }
background { White }
#declare MySphere = sphere_sweep {
linear_spline
4,
<-5, -5, 0>, 1
<-5, 5, 0>, 1
< 5, -5, 0>, 1
< 5, 5, 0>, 1 }
//#declare MySphere = cylinder { <-1, -3, -1>, <1, 3, 1> 0.5 }
object {
MySphere
texture {
pigment { rgb 1}
}
}
#declare R1 = seed(33);
#declare Cnt = 0;
#while (Cnt<500)
#declare Norm = <0, 0, 0>;
#declare Start = vrotate (<0,0,-2>, <asind(rand(R1)*2-1),rand(R1)*360,0>);
#declare Inter = trace ( MySphere, Start, <0, 0, 0>-Start, Norm );
#debug concat(vstr(3,Start,",",3,3)"n")
#if (vlength(Norm)!=0)
cylinder {
Inter, Inter+Norm, .1
texture {
pigment {color red 1}
}
}
#end
#declare Cnt = Cnt+1;
#end
Post a reply to this message
|
![](/i/fill.gif) |